<?php

use Illuminate\Database\Seeder;
use App\Role;
use App\Permission;
use App\Admin;
class RoleSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
       $user = ['email'=>'admin@qq.com','name'=>'admin','password'=>bcrypt('123456')];
       $test = ['email'=>'test@qq.com','name'=>'test','password'=>bcrypt('123456')];

       //创建用户
       $user = Admin::create($user);
       $test = Admin::create($test);

       //创建角色普通
       $testRole = Role::create([
       		'name'=>'user',
       		'display_name'=>'user',
       		'description'=>'普通管理员',
       	]);

       //创建角色超级
       $adminRole = Role::create([
       		'name'=>'admin',
       		'display_name'=>'admin',
       		'description'=>'超级管理员',
       	]);

       //把角色付给用户
       $user -> attachRole($adminRole);
       $test -> attachRole($testRole);

    }
}
